package com.yan;

import com.yan.base.AlertRule;
import com.yan.base.Notification;
import com.yan.handlers.ErrorAlertHandler;
import com.yan.handlers.TpsAlertHandler;

/**
 * @author yanheng
 * @data 2019/12/31 17:20
 */
public class ApplicationContext {
    private AlertRule rule;
    private Notification notification;
    private Alert alert;

    public void initializeBeans() {
        rule = new AlertRule();
        notification = new Notification();
        alert = new Alert();
        alert.addAlertHandler(new TpsAlertHandler(rule, notification));
        alert.addAlertHandler(new ErrorAlertHandler(rule, notification));
    }

    public Alert getAlert() {
        return alert;
    }

    private static final ApplicationContext instance = new ApplicationContext();

    private ApplicationContext() {this.initializeBeans();}

    public static ApplicationContext getInstance() {
        return instance;
    }
}
